void printArray(float* data, int size){
  //if(size>27) size = 12;//temporary! remove this line later
  for(int i = 0; i< size; i++){//the first few are the same
    Serial.print(data[i],3);
    Serial.print("\t");
  }
  Serial.println();
}



void printPatternScores(int _numPatterns, Pattern** _patterns){
Serial.println(F("========================"));
    for(int i = 0; i < _numPatterns; i++){
      Serial.print(F("PatternID_")); 
      Serial.print(i);
      Serial.print(F("_Score:  "));
      Serial.println(_patterns[i]->score);
    }
    Serial.println();
    Serial.println();
}


int outputPatternSound(float* Patterns, int lastOutput){
int scoreThreshold = 5;
//FIND OUT WHICH PATTERN HAD THE LARGEST SCORE
  if(Patterns[0] > Patterns[1] 
  && Patterns[0] > Patterns[2]
  && Patterns[0] > Patterns[3]
  && Patterns[0] > Patterns[4]
  && Patterns[0] > Patterns[5]
  && Patterns[0] > scoreThreshold){
    
    if(lastOutput != 0){
      lastOutput = 0;
      Serial1.print("f");
      Serial1.print("<eoc>");
      return lastOutput;
    }    
  }
  else if(Patterns[1] > Patterns[0] 
  && (Patterns[1] > Patterns[2])
  && (Patterns[1] > Patterns[3])
  && Patterns[1] > Patterns[4]
  && Patterns[1] > Patterns[5]
  && Patterns[1] > scoreThreshold){
    if(lastOutput != 1){
      lastOutput = 1;
      Serial1.print("b");
      Serial1.print("<eoc>");
            return lastOutput;
    }
  }
  else if
  (Patterns[2] > Patterns[0] 
  && Patterns[2] > Patterns[1]
  && Patterns[2] > Patterns[3]
  && Patterns[2] > Patterns[4]
  && Patterns[2] > Patterns[5]
  && Patterns[2] > scoreThreshold){
if(lastOutput != 2){
      lastOutput = 2;
      Serial1.print("l");
      Serial1.print("<eoc>");
            return lastOutput;
    }
  }
  else if
  (Patterns[3] > Patterns[0] 
  && Patterns[3] > Patterns[1]
  && Patterns[3] > Patterns[2]
  && Patterns[3] > Patterns[4]
  && Patterns[3] > Patterns[5]
  && Patterns[3] > scoreThreshold){
if(lastOutput != 3){
      lastOutput = 3;
      Serial1.print("r");
      Serial1.print("<eoc>");
            return lastOutput;
    }
  }
  else if
    (Patterns[4] > Patterns[0] 
  && Patterns[4] > Patterns[1]
  && Patterns[4] > Patterns[2]
  && Patterns[4] > Patterns[3]
  && Patterns[4] > Patterns[5]
  && Patterns[4] > scoreThreshold){
    if(lastOutput != 4){
          lastOutput = 4;
          Serial1.print("t");
          Serial1.print("<eoc>");
                return lastOutput;
        }
  }
  else if
    (Patterns[5] > Patterns[0] 
  && Patterns[5] > Patterns[1]
  && Patterns[5] > Patterns[2]
  && Patterns[5] > Patterns[3]
  && Patterns[5] > Patterns[4]
  && Patterns[5] > scoreThreshold){
if(lastOutput != 5){
      lastOutput = 5;
      Serial1.print("s");
      Serial1.print("<eoc>");
    }
  }
  return 8;
}

//====================================================================


//--------------------- Not currently used --------------------------

void printResults(int _numPatterns, double* _results){
 double total = 0;
 for(int i = 0; i < _numPatterns; i++){
   total = total + _results[i];
   
 }
 for(int i = 0; i < _numPatterns; i++){
   Serial.print("Pattern_"); 
   Serial.print(i); 
   Serial.print(": ");
   Serial.print((_results[i] / total) * 100);
   Serial.print("%"); 
   Serial.print("\t");
 }
  Serial.println();
}
//====================================================================
/*
void printResultsRaw(int _numPatterns, double* results){
 double total = 0;
 for(int i = 0; i < _numPatterns; i++){
   total = total + results[i];  
 }
 for(int i = 0; i < _numPatterns; i++){
     Serial.print((results[i] / total) * 100);Serial.print("\t");
 }
 Serial.println();
}*/
